<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@page import="language.Hebrew"%>
<%@page import="language.LangIntrf"%>
<%@page import="model.HistoryLog"%>
<%@page import="com.google.appengine.repackaged.org.json.JSONObject"%>
<%@page import="controller.Controller"%>
<%@ page import="java.util.*,dataBase.*"%>
<%@ page import="com.google.appengine.api.users.UserService"%>
<%@ page import="com.google.appengine.api.users.UserServiceFactory"%>

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>CheckIt</title>
  </head>

  <body>
    <h1>Add Order Page</h1>
	<%= session.getAttribute("userNameBusiness")%>
    <table>
      <tr>
        <td colspan="2" style="font-weight:bold;">Available Servlets:</td>        
      </tr>
      <tr>
        <td><a href="checkit">CheckIt</a></td>
      </tr>
      <tr>
        <td><a href="logInBusiness">logInBusiness</a></td>
      </tr>
    </table>
    
    <br>
    <br>
    <%    
    	Business bizHistory = Controller.getInstance().getBiz("ran");
		if (bizHistory!=null)
		{
    		List<String> historyLog = bizHistory.getHistoryLog();
    		System.out.println("historyLog "+ historyLog);
	    	for (String jsonRecord : historyLog)
	    	{
	    		JSONObject jsonObject = new JSONObject(jsonRecord);
	    		System.out.println(new Hebrew().getDirection());
	    		%> <%=HistoryLog.getInst().getHistoryLogRecord(jsonRecord,new LangIntrf(),true)%> <br> <%
	    	}
		}
    %>
    
    <br>
    <br>
    <form action="logInBusiness" method="POST">
        User Name: <input type="text" name="userName1" size="20"><br>
        Password: <input type="text" name="password" size="20">
        <br><br>
        <input type="submit" value="Submit">
	</form> 
    
    <form action="createAccountBusiness" enctype="multipart/form-data" method="POST">
		<p> User Name: <input type="text" name="userName" size="20"> </p> <br>
		<p> file: <input type="file" name="file" size="20"> </p> <br>
		<div><input type="Submit" value="Upload File"> </div> <br>
	</form> 
	
	<img src="http://chart.apis.google.com/chart?cht=qr&chs=200x200&chl=<%=Controller.getInstance().getSyncaWebAddress()%>/" /> 
	
		
	<form id="myform2"  enctype="multipart/form-data" method="post" action="business/addAdBusiness" accept-charset="ISO-8859-1">
    <input type="file"  id="bizLogo"  name="bizLogo" title="upload your business logo" accept="image/*"/>
    <button class="formButton" type="submit" id="submitButton" >send</button>
    </form>
              
        
          
    <%
    	String bizUserName = (String)session.getAttribute("userNameBusiness");
    	if (bizUserName!=null)
    	{
	   		Business b = Controller.getInstance().getBiz(bizUserName);
	   		if (b!=null)
	   		{
		    	int size = b.getAds().size();
		    	for (int i=0; i<size; i++)
		    	{
		    		%>
		    		<img src="/showImage?imageKey=<%=bizUserName %>&id=<%=i %>" />
		    		<%
		    	}
	    	}
    	}
    
    %>  
    
    <%
    
    	Business biz = Controller.getInstance().getBiz("sivanbiz");
		if (biz!=null)
		{
    		Long[] orderTime = biz.getOrderUrgencyTime();
    		System.out.println("orderTime length "+orderTime.length);
	    	for (int i=0; i<orderTime.length; i++)
	    	{
	    		%> <%=orderTime[i] %> <%
	    	}
		}
    %>
    
    <%
    
    	String a = "{b: \"av ad\"}";
		JSONObject json = new JSONObject(a);
		%>
		<%= json.get("b")%><%
    %>
    <br>
    <br>
    <%UserService userService = UserServiceFactory.getUserService(); %>
    <a href="<%=userService.createLogoutURL("")%>">log out</a>
  </body>
</html>
